<?php

class Db_Tables_TopBanners extends Zend_Db_Table
{
    protected $_name = 'top-banners';
	var $level;
	var $level_id;
	var $load_all;
	var $channel_id;
	
	function LoadBanners()
	{
		$result = array();
		
		if($this->level)
		{
			$level = $this->level;
		}else{
			$level = 0;
		}
		
		if($this->level_id)
		{
			$level_id_con = " and level_id=".$this->level_id;
		}else
		{
			$level_id_con = "";
		}
		
		if(is_numeric($this->channel_id))
		{
			$channel_id_con = " and channel_id=".$this->channel_id;
		}else
		{
			$channel_id_con = "";
		}
		
		$rows = $this->fetchAll("level=".$level.$level_id_con.$channel_id_con, "tb_id ASC");

		if($rows)
		{
			foreach($rows as $row)
			{
				if($this->load_all)
				{
					$result[$row['tb_id']] = array(
						'image_url' => $row['image_url'],
						'target_url' => $row['target_url']
					);
				}else{
					if($row['image_url'])
					{
						$result[$row['tb_id']] = array(
							'image_url' => $row['image_url'],
							'target_url' => $row['target_url']
						);
					}
				}
			}
		}
			
		return $result;
	}
}